<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/decorators/taglibs.jsp"%>
	<div class="container">
		<div class="row">
			<div class="panel panel-info">
				<div class="panel-heading">
					${status.text }
				</div>
		 		<c:if test="${status.retweetedStatus != null }">
				 	<div class="panel-body">
				 			<label class="text-primary">@${status.retweetedStatus.user.screenName }</label>
				    		${status.retweetedStatus.text}
				    </div>
		    	</c:if>
		    	<div class="panel-footer">
		    		<p class="text-left">
		    			<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${status.createdAt}" type="both"/> 来自:${status.source.name}
		    		</p>
		    		<p class="text-right">
						 转发(${status.repostsCount }) <a href="#" class="comment" id="a_comment">评论(${status.commentsCount })</a>
		    		</p>
		    		<div class="form-group">
						<textarea cols="80" rows="3" id="content" class="form-control" placeholder="请输入评论内容"></textarea><br>
						<input id="comment" type="button" class="btn btn-primary pull-right" value="评论">
					</div>
					<div class="form-group">
						<label for="email">@人员</label>
						<div id="myFollows" class="row">
							<c:forEach var="user" items="${users.users }" varStatus="status">
								<div class="col-md-3">
									<input type="checkbox" name="follow" value="${user.screenName }">
									${user.screenName }
								</div>
							</c:forEach>
						</div>
						<div class="col-md-offset-3">
							<ul class="pagination">
							  <li><a href="#">&laquo;</a></li>
							  <c:forEach var="i" begin="1" end="${users.totalNumber/50 + 1}"> 
							  	<li><a href="${ctx }/weibo/home/${status.id }?page=${i }">${i }</a></li>
							  </c:forEach>
							  <li><a href="#">&raquo;</a></li>
							</ul>
						</div>
					</div>
				</div>
			</div>
		    <hr>
		</div>
	</div>
	<script type="text/javascript">
		$(".btn-primary").click(function(){ 
			var atUser = getSelected();
			$.ajax({
				type : "POST", 
				async: false, 
				dataType: "json",
				url : "${ctx}/api/create_comment", 
				data : {
					id:"${status.id}",
					comment:$("#content").val(),
					at_user: atUser
					},
				success : function(result)
				{
					$("#a_comment").html("评论("+result.data+")");
				}
			});  
	   });
		//获取选中的人员
		function getSelected(){
			var name="";
			var arrChk=$("input[name='follow']:checked");
			arrChk.each(function(){ 
				if(name == ""){
					name += this.value;
				}else{
					name += ","+this.value;
				}
			}); 
			return name;
		};
	</script>
	